package rmaqlc31.basic;

import java.util.Scanner;

public class J07_CalrendarV1 {

	public static void main(String[] args) {
		// 2005년 1월 달력 출력
		
		final String TITLE = "\t\t   January 2005";
		final String HDRLINE = "---------------------------------------------------";
		final String HDRDAYS = "Sun\tMon\tTue\tWed\tThu\tFri\tSat";
		
		
		Scanner sc = null;
		
		int a;
		int skipday;
		
		sc = new Scanner(System.in);
		
		System.out.println("년도를 입력하세요 : ");
		a = sc.nextInt();
		
		System.out.println(TITLE);
		System.out.println(HDRLINE);
		System.out.println(HDRDAYS);
		
		
		skipday = ((a-1)*365+(a-1)/4-(a-1)/100+(a-1)/400)%7+1;
		
		
		/*// 달력 출력 v1 (공백없이)
		for(int i=1;i<=31;++i){
			if(i%7==0)
				System.out.println(i);
			else
				System.out.print(i+"\t");
		}
		System.out.println();*/
		
		// 달력 출력 v2 (공백포함)
		// int skipday = 6;	// 달력 공백 수
		if (skipday==7)
			skipday=0;
		
		int b = skipday;
		
		for(int i=1;i<=31+b;++i,--skipday){
			if(skipday>=1){
				System.out.print("\t");
				}
			else if(i%7==0)
				
				System.out.println(i-b);
			else
				System.out.print(i-b+"\t");
			}
		
		sc.close();
		
	}

}
